/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.itintegration.catalogue.gui.service.view.capacity;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.camel.Exchange;
import se.sll.itintegration.catalogue.gui.data.CapacityResponse;

/**
 *
 * @author khaleddaham
 */
public class CapacityProcessor {
    public void capacityResponseJSON(Exchange exchange) throws JsonParseException, JsonMappingException, IOException {
        ObjectMapper mapper = new ObjectMapper();
        List<CapacityResponse> responses = mapper.readValue(exchange.getIn().getBody(String.class), new TypeReference<List<CapacityResponse>>() {
        });
        exchange.getIn().setBody(responses);
    }
}
